<!--基本信息-->

<template>
  <div style="padding-left: 40px">
    <div class="flex-start">
      <el-avatar shape="square" :size="100" :src="customer.wxHeadimgUrl">
        <img
          src="https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png"
        />
      </el-avatar>
      <div class="flex-left m-l-20">
        <div>{{ customer.wxNickName }}</div>
        <div class="flex-start m-t-10">
          <span class="m-r-10">{{ customer.userPhone }}</span>
          <el-tag size="small" v-if="customer.userIdentity == 1"
            >车队成员</el-tag
          >
          <el-tag size="small" v-if="customer.userIdentity == 0"
            >普通车主</el-tag
          >
        </div>
      </div>
    </div>
    <el-form
      ref="form"
      :disabled="!isEdit"
      :model="customer"
      :rules="rules"
      label-width="130px"
      size="small"
      style="width: 400px; margin-top: 20px"
    >
      <el-form-item label="注册时间" prop="createTime">
        {{ customer.createTime }}
      </el-form-item>
      <el-form-item label="加注总量" prop="totalActualWeight">
        {{ customer.totalActualWeight }}
      </el-form-item>
      <el-form-item label="加注总金额(元)" prop="totalMoneyFill">
        {{ customer.totalMoneyFill }}
      </el-form-item>
      <el-form-item label="加注次数" prop="totalFillCount">
        {{ customer.totalFillCount }}
      </el-form-item>
      <el-form-item
        label="团队名称"
        prop="totalFillCount"
        v-if="customer.userIdentity == 1"
      >
        {{ customer.teamName }}
      </el-form-item>
    </el-form>
    <div class="f f-a-c" style="margin-left: 100px">
      <el-button size="small" type="primary" @click="back">返回</el-button>
    </div>
  </div>
</template>

<script>
// import {teamSubmit} from "../../../api/customer";

export default {
  name: "basicinfo",
  data() {
    return {
      isEdit: false,
      rules: {
        teamName: [
          { required: true, message: "请输入团队名称", trigger: "blur" },
        ],
        concatName: [
          { required: true, message: "请输入联系人", trigger: "blur" },
        ],
        concatPhone: [
          { required: true, message: "请输入联系人电话", trigger: "blur" },
        ],
        agreePrice: [
          { required: true, message: "请输入协议价格(元)", trigger: "blur" },
        ],
        creditMoney: [
          { required: true, message: "额度使用上限(元)", trigger: "blur" },
        ],
        billDay: [
          { required: true, message: "请输入到期(天)", trigger: "blur" },
        ],
      },
    };
  },
  props: {
    customerId: {
      type: Number,
      default: "",
    },
    customer: {
      type: Object,
    },
  },
  created() {
    this.$set(this.customer, "hasAgreePrice", this.customer.agreePrice ? 1 : 0);
  },
  methods: {
    back() {
      console.log("back");
      this.$emit("back", "list");
    },
    saveInfo() {
      let customer = { ...this.customer };
      this.$refs.form.validate().then((res) => {
        if (customer.hasAgreePrice === 0) {
          customer.agreePrice = 0;
        }
        teamSubmit({ ...customer }).then((res) => {
          this.$message.success("修改成功！");
          this.isEdit = false;
        });
      });
    },
  },
};
</script>

<style lang="scss" scoped>
.header {
  .header-img {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    overflow: hidden;
  }

  .name {
    margin-left: 30px;
  }
}

.phone {
  margin-top: 30px;
  font-size: 24px;
  font-weight: bold;
}

.balance {
  margin-top: 20px;
  padding: 5px 0;
  width: 178px;
  border-radius: 50px;
  background-color: rgba(248, 248, 248, 100);
  text-align: center;
  border: 1px solid rgba(255, 255, 255, 100);

  .money {
    font-size: 16px;
    font-weight: bold;
  }
}

.group {
  margin-top: 30px;
  width: 400px;

  .name {
    width: 200px;
  }

  .value {
    font-size: 12px;
    font-weight: bold;
  }
}
</style>
